/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rultax.neural;

/**
 *
 * @author scottw
 */
public abstract class AbstractNetwork {
    private InputNeuron[] inputLayer;
    private HiddenNeuron[] hiddenLayer;
    private OutputNeuron[] outputLayer;
    
    public double[] singlePass(double[] input) throws InvalidNeuronConfigException{
	if(input.length != inputLayer.length)
	    throw new InvalidNeuronConfigException("Number of inputs and number of input layer neurons are not equal");
	
	double[] inputOutput = new double[inputLayer.length];
	for(int i = 0; i < input.length; i++){
	    inputLayer[i].setInput(input[i]);
	    inputOutput[i] = inputLayer[i].process();	    
	}
	
	double[] hiddenOutput = new double[hiddenLayer.length];
	for(int i = 0; i < hiddenLayer.length; i++){
	    hiddenLayer[i].setInput(inputOutput);
	    hiddenOutput[i] = hiddenLayer[i].process();
	}
	    
	double[] outputOutput = new double[outputLayer.length];
	for(int i = 0; i < outputLayer.length; i++){
	    outputLayer[i].setInput(hiddenOutput);
	    outputOutput[i] = outputLayer[i].process();
	}
	
	return outputOutput;
    }

    protected HiddenNeuron[] getHiddenLayer() {
	return hiddenLayer;
    }

    protected void setHiddenLayer(HiddenNeuron[] hiddenLayer) {
	this.hiddenLayer = hiddenLayer;
    }

    protected InputNeuron[] getInputLayer() {
	return inputLayer;
    }

    protected void setInputLayer(InputNeuron[] inputLayer) {
	this.inputLayer = inputLayer;
    }

    protected OutputNeuron[] getOutputLayer() {
	return outputLayer;
    }

    protected void setOutputLayer(OutputNeuron[] outputLayer) {
	this.outputLayer = outputLayer;
    }
}
